import React, { Component } from 'react';
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux';

@connect(
  // mapStateProps
  (state) => ({count1: state.count}), // count1会直接挂在到props上
  // mapDispatchToProps object | fuction
  // {
  //   add: () => ({
  //     type: 'ADD'
  //   })
  // }
  (dispatch) => {
    const add = () =>  dispatch({type: 'ADD'})
    const minus = () =>  dispatch({type: 'MINUS'})
    let creators = {
      add: () => ({type: 'ASDD'}),
      aminusdd: () => ({type: 'MINUS'}),
    }
    creators = bindActionCreators(creators, dispatch); // bindActionCreators creators 和dispatch做了结合
    return { dispatch, ...creators }
  }

)
class ReachReduxPage extends Component {
  state = {}

  render() {
    console.log(this.props)
    return (
      <div>ReachReduxPage</div>
    )
  }
}

export default ReachReduxPage